package com.tjnmt.togo.BroadcastReceiver;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.tjnmt.togo.utils.PowerManagerUtil;

/**
 * 监控屏幕状态的广播,防止屏幕保护时上传位置数据失败。
 */
public class PowerReceiver extends BroadcastReceiver {
    @SuppressLint("Wakelock")
    @Override
    public void onReceive(final Context context, final Intent intent) {
        final String action = intent.getAction();

        if (Intent.ACTION_SCREEN_OFF.equals(action)) {
            //获得唤醒锁。
            PowerManagerUtil.acquireWakeLock();
            Log.e("TAG","唤醒");
        } else if (Intent.ACTION_SCREEN_ON.equals(action)) {
            //释放唤醒锁。
            PowerManagerUtil.releaseWakeLock();
            Log.e("TAG","释放");
        }
    }
}
